package luogu;

import java.io.*;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Queue;

public class A2392 {
static BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter log=new BufferedWriter(new OutputStreamWriter(System.out));
    static int res=0;
    public static void main(String[] args) throws IOException {
        int[] nums=new int[5];
        //接收第一行四个数字
        String[] s = read.readLine().split(" ");
for(int i=1;i<=4;i++){
    nums[i]=Integer.parseInt(s[i-1]);
}

for(int i=1;i<=4;i++){
    int num=nums[i];//当前要接收的数字
    String[] s1 = read.readLine().split(" ");
    PriorityQueue<Integer> q=new PriorityQueue<>((a,b)->{return b-a;});
    for(int j=0;j<num;j++){
        q.offer(Integer.parseInt(s1[j]));
    }
    while(!q.isEmpty()){
      if(q.size()==1){
          Integer poll = q.poll();
          res+=poll;
          break;
      }
        Integer a = q.poll();
      Integer b=q.poll();
      if(a==b){
          res+=a;
      }
      else{
          //a>b
          res+=b;
          q.offer(a-b);
      }
    }
}
        System.out.println(res);
    }
}
